package com.pattern.decorator;

public class MainClient {

    /*
        Decorator Pattern focuses on dynamically adding functions to an object (跟子类一样，本类不能继承的时候才考虑用本模式),
        while Proxy Pattern focuses on controlling access to an object.
     */
    public static void main(String[] args) {
        System.out.println("***Decorator pattern Demo***\n");
        ConcreteComponent withoutDecorator = new ConcreteComponent();
        withoutDecorator.makeHouse();
        System.out.println("_________________");

        //Using a decorator to add floor
        System.out.println("Using a Floor decorator now.");
        FloorDecorator floorDecorator = new FloorDecorator(withoutDecorator);
        floorDecorator.setTheComponent(withoutDecorator);
        floorDecorator.makeHouse();
        System.out.println("_________________");

        //Using a decorator to add floor to original house and then
        //paint it.
        System.out.println("Using a Paint decorator now.");
        //Adding results from floor decorator
        PaintDecorator paintDecorator = new PaintDecorator(floorDecorator);
        paintDecorator.makeHouse();
        System.out.println("_________________");
    }

}
